﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
{% load static %}
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>登录配置</title>
    <link href="{% static 'assets/css/bootstrap.css' %}" rel="stylesheet"/>
    <link href="{% static 'assets/css/font-awesome.css' %}" rel="stylesheet"/>
    <link href="{% static 'assets/js/morris/morris-0.4.3.min.css' %}" rel="stylesheet"/>
    <link href="{% static 'assets/css/custom-styles.css' %}" rel="stylesheet"/>

</head>

<body>
<div id="wrapper">
    <!-- 头部bar -->
    <nav class="navbar navbar-default top-navbar" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/admin/index">POM - 自动化测试平台
            </a>
        </div>
        <ul class="nav navbar-top-links navbar-right color-white">
            <li>
                <a href="/login/" class=" pointer">退出登录</a>
            </li>
            <li><span class="mar-rignt-100">{{user}}</span></li>
        </ul>
    </nav>
    <!-- 头部bar end -->
    <!-- 左侧导航  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">

                <li>
                    <a href="/admin/index"><i class="fa fa-dashboard"></i> 系统概括</a>
                </li>
                <li>
                    <a href="/admin/project"><i class="fa fa-desktop"></i> 项目管理</a>
                </li>
                <li>
                    <a href="/admin/page"><i class="fa fa-bar-chart-o"></i> 页面管理</a>
                </li>
                <li>
                    <a href="/admin/element"><i class="fa fa-qrcode"></i> 页面元素</a>
                </li>

                <li>
                    <a href="/admin/keyword"><i class="fa fa-table"></i> 关键字库</a>
                </li>
                <li>
                    <a href="/admin/testcase"><i class="fa fa-edit"></i> 测试用例 </a>
                </li>
                <li>
                    <a href="/admin/result"><i class="fa fa-fw fa-file"></i> 测试结果 </a>
                </li>
                <li>
                    <a class="active-menu" href="/admin/loginConfig"><i class="fa fa-fw fa-building-o"></i> 登录配置 </a>
                </li>
                <li>
                    <a href="/admin/task"><i class="fa fa-fw fa-sitemap"></i> 任务管理 </a>
                </li>
            </ul>
        </div>

    </nav>
    <!-- 左侧导航  -->
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="page-header">
                        登录配置
                    </h1>
                </div>
            </div>
            <!-- /. ROW  -->
            <!-- /. 表格  -->
            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <!--<div class="panel-heading">表格名字</div>-->
                        <div class="panel-body" style="min-height:600px">
                            <div class="row mar-bottom-20">
                                <div class="col-lg-12">
                                    <div class="form-inline">
                                        <div class="form-group">
                                            <input id='loginName' type="text" class="form-control" placeholder="登录名称">
                                        </div>
                                        <div class="form-group">
                                            <!--<label class="sr-only" for="name">名称</label>-->
                                            <select class="form-control" id="name_xm">
                                                <option>所属项目</option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label width-80 text-right">创建时间：</label>
                                            <div class="form-control-custom">
                                                <div class="input-group date form_datetime width-200" id="pzTime"
                                                     data-date="2018-01-01" data-date-format="yyyy-mm-dd"
                                                     data-link-field="dtp_input_start">
                                                    <input class="form-control" size="16" type="text" value=""
                                                           placeholder="开始时间" readonly>
                                                    <span class="input-group-addon"><span
                                                            class="glyphicon glyphicon-th"></span></span>
                                                </div>
                                                <input type="hidden" id="dtp_input_start" value=""/>
                                            </div>

                                            <div class="form-control-custom">
                                                <div class="input-group date form_datetime width-200" id="pzqxTime"
                                                     data-date="2018-01-01" data-date-format="yyyy-mm-dd"
                                                     data-link-field="dtp_input_end">
                                                    <input class="form-control" size="16" type="text" value=""
                                                           placeholder="结束时间" readonly>
                                                    <span class="input-group-addon"><span
                                                            class="glyphicon glyphicon-th"></span></span>
                                                </div>
                                                <input type="hidden" id="dtp_input_end" value=""/>

                                            </div>

                                        </div>

                                        <button type="submit" class="btn btn-primary" onclick="search()">搜索</button>
                                        <a class="btn btn-info" href="/admin/loginConfig/create">新建</a>
                                    </div>

                                </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>登录名称</th>
                                        <th>所属项目</th>
                                        <th>创建时间</th>
                                        <th>所需参数</th>
                                        <th>备注信息</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody class="js_table">

                                </table>
                            </div>

                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>

            <!-- /. 表格  -->
            <footer>
                <p class="text-center"></p>
            </footer>
        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
<!-- /. WRAPPER  -->

<!--关联弹窗-->
<div class="modal fade" id="bind" tabindex="-1" role="dialog" aria-labelledby="myModalLabe0" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabe0">环境关联</h4>
            </div>
            <div class="modal-body">
                <!--内容-->
                <div class="form-group f-c">
                    <div id='projectName' class="col-sm-12">
                    </div>
                </div>
                <div class="form-group f-c">
                    <div class="col-sm-12 mar-top-6">
                        <a data-toggle="modal" class="pointer" id="createBind">新建关联</a>
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover" id="result-table">
                                <thead>
                                <tr>
                                    <th>环境</th>
                                    <th>参数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="binds">
                            </table>
                        </div>
                    </div>
                </div>
                <!--内容-->
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>
<!--end 关联弹窗-->
<div class="modal fade" id="del" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel1"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" onclick="cancel()">
                    &times;
                </button>
                <h4 class="modal-title" id="messageTitle">删除配置</h4>
            </div>
            <div class="modal-body">
                <p id="messageContent">请确认是否删除登录配置</p>
                <p id='delMessage' class="js_DELmessage text-danger"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" onclick="cancel()">取消
                </button>
                <button type="button" class="btn btn-primary" id="delButton">确定
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!--新建关联-->
<div class="modal fade" id="newProject" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" onclick="cancelBind()">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    新建关联</h4>
            </div>
            <div class="modal-body">
                <!--内容-->
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <div class="form-group">
                            <label id="pe" class="col-sm-2 control-label">选择环境</label>
                            <div class="col-sm-10">
                                <select id='eselect' class="form-control">
                                    <option>选择环境</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">设置参数</label>
                            <div class="col-sm-10" id="bindParameter">
                                <div class="form-group">
                                    <label for="lastname" class="col-sm-2 control-label">userName</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-sm-2 control-label">element</label>
                                    <div class="col-sm-5">
                                        <select class="form-control">
                                            <option>选择页面</option>
                                            <option>2</option>
                                            <option>3</option>
                                            <option>4</option>
                                            <option>5</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-5">
                                        <select class="form-control">
                                            <option>选择元素</option>
                                            <option>2</option>
                                            <option>3</option>
                                            <option>4</option>
                                            <option>5</option>
                                        </select>
                                    </div>
                                </div>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div id='message' class="col-sm-10 js_message text-danger"></div>
                        </div>
                    </div>
                </form>

                <!--内容-->

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" onclick="cancelBind()">
                    取消
                </button>
                <button type="button" class="btn btn-primary" id="saveBind">
                    保存
                </button>

            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>
<!--end 新建弹窗-->
<script src="{% static 'assets/js/jquery-1.10.2.js' %}"></script>
<script src="{% static 'assets/js/bootstrap.min.js' %}"></script>
<script src="{% static 'assets/js/jquery.metisMenu.js' %}"></script>
<script src="{% static 'assets/js/morris/raphael-2.1.0.min.js' %}"></script>
<script src="{% static 'assets/js/morris/morris.js' %}"></script>
<script src="{% static 'assets/js/dataTables/jquery.dataTables.js' %}"></script>
<script src="{% static 'assets/js/dataTables/dataTables.bootstrap.js' %}"></script>
<script src="{% static 'assets/js/custom-scripts.js' %}"></script>
<script src="{% static 'assets/datetimepicker/bootstrap-datetimepicker.min.js' %}"></script>
<script src="{% static 'assets/datetimepicker/bootstrap-datetimepicker.zh-CN.js' %}"></script>
<script src="{% static 'assets/datetimepicker/moment-with-locales(1).js' %}"></script>

<script>
    seleList();
    search();

    function bindParameterSetting(params) {
        $("#bindParameter").find("div").remove()
        var div = ''
        for (var i = 0; i < params.length; i++) {
            div += '<div class="form-group">';
            div += '<label for="lastname" class="col-sm-2 control-label">' + params[i]["key"] + '</label>';
            div += '<div class="col-sm-10">';
            if (params[i]["type"] == "string") {
                div += '<input type="text" class="form-control" name = "loginParams" data-key="' + params[i]["key"] + '">';
            } else {
                div += '<select class="form-control" class="page">';
                div += '</select>';
                div += '</div>';
                div += '<div class="col-sm-5">';
                div += '<select class="form-control"  name = "loginParams" data-key="\' + params[i]["key"] + \'">';
                div += '</select>'
            }
            div += '</div></div>'
        }
        $("#bindParameter").append(div);
    }

    function cancelBind() {
        $("#newProject").modal("hide");
        $("#bind").modal("show");
    }
    
    function cancel() {
        $("#del").modal("hide");
        {#$("#newProject").modal("hide");#}
        {#$("#projectName").val();#}
        {#$("#remark").val();#}
        {#$("#message").html("");#}
        $("#delMessage").html("");
    }

    function newBind(id) {
        $("#eselect").removeAttr("disabled");
        $("#myModalLabel").html("新建关联")
        $("#message").html("")
        $("#newProject").modal("show");
        $("#bind").modal("hide");
        $("#saveBind").attr("onclick", "addBind(" + id + ")")
        var list = $("#bindParameter").find("[name='loginParams']");
        for (var i = 0; i < list.length; i++) {
            $(list[i]).val("")
        }
    }

    function addBind(id) {
        var parameter = {}
        var list = $("#bindParameter").find("[name='loginParams']");
        var environmentId = $("#eselect option:selected").val()
        for (var i = 0; i < list.length; i++) {
            parameter[$(list[i]).attr("data-key")] = $(list[i]).val();
        }
        $.ajax({
            url: '/api/v1/login/bind/' + id,
            type: 'post',
            contentType: 'application/json',
            dataType: 'json',
            data: JSON.stringify({"environmentId": environmentId, "parameter": parameter}),
            success: function (res) {
                if (res.code == 200) {
                    $("#bind").modal("show");
                    $("#newProject").modal("hide");
                    setTimeout(function () {
                        bind($("#projectName").attr("data"));
                    }, 1000)
                } else {
                    $("#message").html(res.message);
                }
            }
        })
    }

    function bind(id) {
        $("#projectName").attr("data", id);
        $("#createBind").attr("onclick", "newBind(" + id + ")");
        var projectId = 0
        $.ajax({
            url: '/api/v1/login/' + id,
            type: 'post',
            contentType: 'application/json',
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    $("#projectName").html("登录名称：" + res.data.name)
                    $("#binds").find("tr").remove();
                    projectId = res.data.projectId
                    var tr = '';
                    for (var i = 0; i < res.data.bind.length; i++) {
                        tr += '<tr>';
                        tr += '<td class="center">' + res.data.bind[i].environmentName + '</td>'
                        tr += '<td class="center">';
                        var parameters = res.data.bind[i].parameter
                        for (var j in parameters) {
                            tr += (j + " = " + parameters[j]);
                            tr += "</br>"
                        }
                        tr += '</td>';
                        tr += '<td class="center">';
                        tr += '<a class="pointer"  onclick=\'editBind(' + res.data.bind[i].id + ',' + JSON.stringify(parameters) + ',\"' + res.data.bind[i].environmentId + '\")\'>编辑</a>';
                        tr += ' - ';
                        tr += '<a class="pointer" onclick="isDelBind(' + res.data.bind[i].id + ')">删除</a>';
                        tr += '</td></tr>';
                    }
                    bindParameterSetting(res.data.params, [])
                    $("#binds").append(tr)
                    $.ajax({
                        url: '/api/v1/environment?p=1',
                        type: 'post',
                        contentType: 'application/json',
                        dataType: 'json',
                        data: JSON.stringify({"projectId": projectId, "pageSize": 999999}),
                        success: function (res) {
                            if (res.code == 200) {
                                $("#eselect").find("option").remove();
                                var option = '<option value=0>选择环境</option>';
                                for (var i = 0; i < res.data.environments.length; i++) {
                                    option += '<option value="' + res.data.environments[i].id + '">' + res.data.environments[i].name + '</option>';
                                }
                                $("#eselect").append(option);
                            }
                        }
                    });
                }
                else {
                    $("#delMessage").html(res.message);
                }
            }
        });

        $("#bind").modal("show");
    }

    function updateBind(id) {
        var parameter = {}
        var list = $("#bindParameter").find("[name='loginParams']");
        for (var i = 0; i < list.length; i++) {
            parameter[$(list[i]).attr("data-key")] = $(list[i]).val();
        }
        $.ajax({
            url: '/api/v1/login/bind/edit/' + id,
            type: 'post',
            contentType: 'application/json',
            dataType: 'json',
            data: JSON.stringify({"parameter": parameter}),
            success: function (res) {
                if (res.code == 200) {
                    $("#bind").modal("show");
                    $("#newProject").modal("hide");
                    setTimeout(function () {
                        bind($("#projectName").attr("data"));
                    }, 1000)
                } else {
                    $("#message").html(res.message);
                }
            }
        })
    }
    
    function isDelBind(id) {
        $("#messageTitle").html("删除关联")
        $("#messageContent").html("请确认是否取消与此环境的关联")
        $("#message").html("")
        $("#delButton").attr("onclick", "unbind(" + id + ")");
        $("#del").modal("show");
    }

    function editBind(id, params, eid) {
        $("#myModalLabel").html("编辑关联");
        $("#bind").modal("hide");
        $("#message").html("");
        $("#saveBind").attr("onclick", "updateBind(" + id + ")")
        var list = $("#bindParameter").find("[name='loginParams']");
        for (var i = 0; i < list.length; i++) {
            $(list[i]).val(params[$(list[i]).attr("data-key")])
        }
        $("#eselect option[value='" + eid + "']").attr("selected", true);
        $("#eselect").attr("disabled", "disabled");
        $("#newProject").modal("show");
    }


    function unbind(id) {
        $.ajax({
            url: '/api/v1/login/unbind/' + id,
            type: 'post',
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    $("#del").modal("hide");
                    setTimeout(function () {
                        bind($("#projectName").attr("data"));
                    }, 1000)
                } else {
                    $("#delMessage").html(res.message);
                }
            }
        });
    }

    function search() {
        var name, project, startTime, endTime;
        name = $("#loginName").val();           //登录名称
        project = $("#name_xm option:selected").attr('value');  //所属项目
        startTime = $('#dtp_input_start').val()//开始时间
        endTime = $('#dtp_input_end').val()//结束时间
        var data = JSON.stringify({
            "name": name,
            "projectId": project,
            "startTime": startTime,
            "endTime": endTime,
            "pageSize": 99999
        });
        $.ajax({
            url: '/api/v1/login?p=1',
            type: 'post',
            contentType: 'application/json',
            data: data,
            dataType: 'json',
            success: function (res) {
                //重新获取下列表
                $('#dataTables-example').dataTable().fnClearTable();//清空数据.fnClearTable();//清空数据
                $('#dataTables-example').dataTable().fnDestroy(); //还原初始化了的datatable
                var tr = '';
                for (var i = 0; i < res.data.logins.length; i++) {
                    tr += '<tr><td class="center">' + (i + 1) + '</td>';
                    tr += '<td class="center">' + res.data.logins[i].name + '</td>';
                    tr += '<td class="center">' + res.data.logins[i].projectName + '</td>';
                    tr += '<td class="center">' + res.data.logins[i].createTime + '</td>';
                    tr += '<td class="center">' + res.data.logins[i].params.length + '</td>';
                    tr += '<td class="center">' + res.data.logins[i].remark + '</td>';
                    tr += '<td class="center">';
                    tr += '<a href="javascript:void(0);" class="pointer" onclick="bind(' + res.data.logins[i].id + ')">关联</a>';
                    tr += ' - ';
                    tr += '<a href="/admin/loginConfig/edit/' + res.data.logins[i].id + '" class="pointer">编辑</a>';
                    tr += ' - ';
                    tr += '<a href="javascript:void(0);" class="pointer"  onclick="isDel(' + res.data.logins[i].id + ')">删除</a>';
                    tr += '</td></tr>';
                }
                $(".js_table").append(tr)
                $('#dataTables-example').dataTable({
                    "bPaginate": true,  //是否显示分页
                    "bSort": true,     //是否支持排序功能
                    "bAutoWidth": false, //自动宽度
                    "serverSide": false,
                    "pageLength": 10,
                    "sPaginationType": "full_numbers", //分页
                    "oLanguage": {      //多语言配置
                        "sLengthMenu": "每页显示 10 条记录",
                        "sZeroRecords": "对不起，查询不到任何相关数据",
                        "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
                        "sInfoEmtpy": "找不到相关数据",
                        "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                        "sProcessing": "正在加载中...",
                        "oPaginate": {
                            "sFirst": "第一页",
                            "sPrevious": " 上一页 ",
                            "sNext": " 下一页 ",
                            "sLast": " 最后一页 "
                        }
                    },
                });
            }
        });
    }

    function seleList() {
        $("#name_xm,#newSel").find('option').remove();
        $("#name_xm").append('<option value=0>所属项目</option>');
        var data = JSON.stringify({"pageSize": 99999});
        $.ajax({
            url: '/api/v1/project?p=1',
            type: 'post',
            dataType: 'json',
            data: data,
            success: function (res) {
                for (var i = 0; i < res.data.projects.length; i++) {
                    $("#name_xm,#newSel").append('<option value="' + res.data.projects[i].id + '">' + res.data.projects[i].name + '</option>');
                }
            }
        });
    }

    function isDel(id) {
        $("#messageTitle").html("删除配置")
        $("#messageContent").html("请确认是否删除登录配置")
        $("#message").html("")
        $("#delButton").attr("onclick", "del(" + id + ")");
        $("#del").modal("show");
    }

    function del(id) {
        $.ajax({
            url: '/api/v1/login/delete/' + id,
            type: 'post',
            contentType: 'application/json',
            dataType: 'json',
            success: function (res) {
                if (res.code == 200) {
                    $("#del").modal("hide")
                    setTimeout(function () {
                        search();
                    }, 1000)
                } else {
                    $("#delMessage").html(res.message);
                }
            }
        });
    }

    
    
    // function key_select(k) {
    //     k = $(k).val()
    //     // var t = 181;
    //     // for(var i = 0; i <= 8; i++){
    //     //     t += Math.floor(Math.random()*10);
    //     // }
    //     // if (k == 2) {

    //     //     $.ajax({
    //     //         url: 'https://beta.famaomao.com/api/code',
    //     //         type: 'post',
    //     //         contentType: 'application/json',
    //     //         dataType: 'json',
    //     //         data: JSON.stringify({"telephone": t, "pageSize": 999999}),
    //     //         success: function (res) {
    //     //             if (res.code == 200) {
                        
    //     //             } 
    //     //         }
    //     //     });
    //     // } 
    // }

</script>

<script>
    //时间转换
    Date.prototype.Format = function (fmt) { //author: meizz
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
    //获得当前时间
    var newDate = new Date();
    var endTimeT1 = new Date(newDate.getFullYear(), newDate.getMonth(), newDate.getDate()).Format("yyyy-MM-dd");
    $("#pzTime,#pzqxTime").attr("data-date", endTimeT1)
    //开始时间
    $("#pzTime").datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: "month",
        format: 'yyyy-mm-dd',
        forceParse: 0,
        //endDate : new Date()
    }).on('hide', function (event) {
        event.preventDefault();
        event.stopPropagation();
        var startTime = event.date;
        $('#pzqxTime').datetimepicker('setStartDate', startTime);
        $('#pzqxTime').val("");
    });
    //结束时间
    $("#pzqxTime").datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: "month",
        format: 'yyyy-mm-dd',
        forceParse: 0,
        //endDate : new Date()
    }).on('hide', function (event) {
        event.preventDefault();
        event.stopPropagation();
        var endTime = event.date;
        var endTimeT = new Date(endTime.getFullYear(), endTime.getMonth(), endTime.getDate(), 23, 59, 59).Format("yyyy-MM-dd hh:mm:ss");
        $('#pzTime').datetimepicker('setEndDate', endTime);
        $("#dtp_input_end").attr("value", endTimeT)
    });

</script>
</body>

</html>